<template>
      <AgGridVuesCopys :rowHeight="33" :headerHeight="33" :suppressCopyRowsToClipboard="true" rowSelection="multiple" @grid-ready="gridReady" 
          style="height:100%" class='ag-theme-alpine'
          :defaultColDef="defaultColDef" :rowData="table.dataList" 
          :columnDefs="cfsValue" :localeText="localeTextData"/>
    <paginationCopys :total="total" show-total show-jumper 
        show-page-size @change="changePage"  @page-size-change="changeSize" 
        style="justify-content: center;margin-top: 10px;"  :page-size="pagination.pageSize"
        :current="pagination.page" />
</template>

<script lang="ts">
   
   import emitter from "@/hooks/useEventBus";
   import { localeText } from '@/api/aggridZw'
   import { onMounted,reactive, ref } from 'vue';
   import { assTable } from '@/utils/assemblyLevelTable';
   import { Message } from '@arco-design/web-vue';
   import { usePagination, useTable } from '@/hooks/table';

export default {
    name:'repairsProcessed',
    components:{},
    setup () {
        const table = useTable();
        emitter.on("refresh-repairsProcessed", () => {
            pagination.page = 1;
            doRefresh();
        });
        const doRefresh = () => {};
        const pagination = usePagination(doRefresh);
        //表格方面
        const gridOption = ref();
        const gridReady = (params:any) => {
            gridOption.value = params.api; 
            //调整表格自适应大小
        }
        const defaultColDef = {
            sortable: true,
            resizable: true,
            filter: true,
            width: 150
        };
        const editHandler = (data:any) => {

        };
        const checkDetail = (data:any) => {

        };
        const delHeader = (data:any) => {

        };
        let cfsValue:any = [
            {
                headerName: "序号",
                field: "serialNo",
            },
            {
                headerName: "回修流转卡",
                field: "circulatCard",
            },
            {
                headerName: "开单日期",
                field: "billDate",
            },
            {
                headerName: "流转卡号",
                field: "serialNo",
            },
            {
                headerName: "回修车间",
                field: "serialNo",
            },
            {
                headerName: "计划单号",
                field: "serialNo",
            },
            {
                headerName: "客户名称",
                field: "serialNo",
            },
            {
                headerName: "布号",
                field: "serialNo",
            },
            {
                headerName: "品名",
                field: "serialNo",
            },
            {
                headerName: "纱支",
                field: "serialNo",
            },
            {
                headerName: "色号",
                field: "serialNo",
            },
            {
                headerName: "色称",
                field: "serialNo",
            },
            {
                headerName: "门幅",
                field: "serialNo",
            },
            {
                headerName: "克重",
                field: "serialNo",
            },
            {
                headerName: "重量",
                field: "serialNo",
            },
            {
                headerName: "匹数",
                field: "serialNo",
            },
            {
                headerName: "原重量",
                field: "serialNo",
            },
            {
                headerName: "原匹数",
                field: "serialNo",
            },
            {
                headerName: "单位",
                field: "serialNo",
            },
            {
                headerName: "备注",
                field: "serialNo",
            },
            {
                headerName: "坯布编号",
                field: "serialNo",
            },
            {
                headerName: "回修性能",
                field: "serialNo",
            },
            {
                headerName: "退货部门",
                field: "serialNo",
            },
            {
                headerName: "扣款日期",
                field: "serialNo",
            },
            {
                headerName: "扣款金额",
                field: "serialNo",
            },
            {
                headerName: "生产交期",
                field: "serialNo",
            },
            {
                headerName:'操作',   
                lockPosition:'right',
                sortable:false,
                resizable:false,
                filter:false,
                width:150,
                cellRenderer:{
                    template:`
                    <a-tag color="#eec216" @click="a" class="gesture">修改</a-tag>
                    <a-tag color="#00d223" @click="b" class="gesture">明细</a-tag>
                    <a-tag color="#ee1633" @click="c" class="gesture">删除</a-tag>
                    `,
                    setup(props:any) {
                        const a = () => {
                            editHandler(props.params.data);
                        }; 
                        const b = () => {
                            checkDetail(props.params.data);
                        };
                        const c = () => {
                            delHeader(props.params.data);
                        }; 
                        return {
                            a,b,c
                        }
                    }
                }
            },
        ];
        let a = [{
            showRowGroup: 'hide_def',
            "headerName": "",
            "checkboxSelection": true,
            "headerCheckboxSelection": true,
            "pinned": "left",
            "width": 50,
            resizable: false,
            filter: false,
            sortable: false,
            minWidth: 50,
            maxWidth: 50,
            lockPosition: "left",
        }]
        cfsValue = a.concat(cfsValue);
        const total = ref(10);
        const changePage = (val:any) => {
            pagination.page = val
            doRefresh();
        }
        const changeSize = (val:any) => {
            pagination.pageSize = val
            doRefresh();
        }

        const localeTextData :any = ref(localeText);
        emitter.on('export-repairsProcessed',() => { 
            let selectList = gridOption.value.getSelectedRows();
            // console.log(selectList);
            if (selectList.length === 0) {
                Message.error('请勾选需要导出的数据')
                return
            } else {
                //导出数据
                let nowRow = table.dataList.filter(function (o) {
                    return (gridOption.value.getSelectedRows().map((o: any) => { return o.id })).indexOf(o["id"]) !== -1;
                })
                assTable(cfsValue,nowRow,'车间退库信息(待处理)');
            }
        });
        return {
            pagination,
            table,
            localeTextData,
            changePage,
            changeSize,
            total,
            cfsValue,
            defaultColDef,
            gridReady,
        }
    }
}
</script>

<style  scoped>

</style>